﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace INF1010_Chat
{
    public class Group
    {
        private string name;
        private UserList users;

        private Group()
        {

        }

        public Group(string name)
        {
            this.name = name;
            this.users = new UserList();
        }

        public string Name
        {
            get
            {
                return name;
            }
        }

        public List<User> Users
        {
            get
            {
                return users.Users.ToList();
            }
        }

        public void AddUser(User user)
        {
            if (!users.Users.Contains(user))
                users.AddUser(user);
        }

        public void RemoveUser(User user)
        {
            if (users.Users.Contains(user))
                users.RemoveUser(user);
        }

        
        public string Serialize()
        {
            return name;
        }

        public static Group Deserialize(string source)
        {
            Group group = new Group();
            group.name = source;
            return group;
        }

        public override string ToString()
        {
            return name;
        }
    }
}
